<?php
require_once("config.php");
require_once("header.php");
require_once("functions.php");
?>
<p><strong>Enter your URL: </strong></p>
<FORM name="keyworddensitytool" action="keyword-density.php" method="post">
  <INPUT maxLength="255" size="40" value="<?php if(isset($_REQUEST['seotools_url'])) echo $_REQUEST['seotools_url']; else echo 'http://'; ?>" name="seotools_url">
  <INPUT name="submit" type="submit" value="Lookup">
</FORM>
<p>&nbsp;</p>
<?php

if (isset($_REQUEST['submit']) && isset($_REQUEST['seotools_url']) )
{

	$page = $_REQUEST['seotools_url'];
	
	list($headers, $contents) = read_fsock($page);

?>
<table width="98%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td align="center"><table width="96%" border="0" cellspacing="1" cellpadding="6">
      <tr>
        <td width="14%" height="25" class="tr1">URL Analyzed:</td>
        <td width="86%" class="tr2"><a href="<?php echo $page; ?>" target="_blank"><?php echo $page; ?></a></td>
      </tr>
      <tr>
        <td height="25" class="tr1">HTTP Code:</td>
        <td class="tr2"><?php echo $headers[0]; ?></td>
      </tr>
      <tr>
        <td height="25" class="tr1">Page Length: </td>
        <td class="tr2"><?php echo round(strlen($contents)/1024,2); ?> K</td>
      </tr>
      <tr>
        <td height="25" align="left" valign="top" class="tr1">All Text:</td>
        <td class="tr2" style="font-size:11px"><div class="seotools_scroll"><?php echo $main_text = get_text_only($contents); ?></div></td>
      </tr>
      <tr>
        <td height="25" align="left" valign="top" class="tr1">Important Text:</td>
        <td class="tr2" style="font-size:11px"><div class="seotools_scroll"><?php 
		list($total, $imp_text) = get_imp_text($main_text);
		echo $imp_text; ?></div></td>
      </tr>
      <tr>
        <td height="25" align="left" valign="top" class="tr1">Density Tables:</td>
        <td class="tr2"><table width="98%" border="0" cellspacing="1" cellpadding="1">
          <tr>
            <td align="center" valign="top"><table width="98%" border="0" cellspacing="1" cellpadding="1">
              <tr>
                <td height="25" colspan="3" class="headingbar"><strong>One-Word Keywords</strong></td>
              </tr>
              <tr class="statusbg">
                <td height="24">Word</td>
                <td height="24" align="center">Density</td>
                <td height="24" align="center">Count</td>
              </tr>
			  <?php
			  $tr = 0;
			  $words = get_1words($imp_text);
			  arsort($words);
			  foreach($words as $w=>$r)
			  {
			  if ($r == 1) continue;
			  ?>
              <tr class="tr<?php echo (($tr%2 == 0)?'1':'2'); ?>">
                <td align="left"><?php echo $w; ?></td>
                <td align="center"><?php echo round( ($r * 100) / count($words),2); ?></td>
                <td align="center"><?php echo $r; ?></td>
              </tr>
			  <?php
			  $tr++;
			  }
			  ?>
              <tr>
                <td colspan="3">&nbsp;</td>
              </tr>
            </table></td>
            <td width="33%" align="center" valign="top"><table width="98%" border="0" cellspacing="1" cellpadding="1">
              <tr>
                <td height="25" colspan="3" class="headingbar"><strong>Two-Word Keywords</strong></td>
              </tr>
              <tr class="statusbg">
                <td height="24">Word</td>
                <td height="24" align="center">Density</td>
                <td height="24" align="center">Count</td>
              </tr>
              <?php
			  $tr = 0;
			  $words = get_2words($imp_text);
			  arsort($words);
			  foreach($words as $w=>$r)
			  {
			  if ($r == 1) continue;
			  ?>
              <tr class="tr<?php echo (($tr%2 == 0)?'1':'2'); ?>">
                <td align="left"><?php echo $w; ?></td>
                <td align="center"><?php echo round( ($r * 100) / count($words),2); ?></td>
                <td align="center"><?php echo $r; ?></td>
              </tr>
			  <?php
			  $tr++;
			  }
			  ?>
              <tr>
                <td colspan="3">&nbsp;</td>
              </tr>
            </table></td>
            <td width="33%" align="center" valign="top"><table width="98%" border="0" cellspacing="1" cellpadding="1">
              <tr>
                <td height="25" colspan="3" class="headingbar"><strong>Three-Word Keywords</strong></td>
              </tr>
              <tr class="statusbg">
                <td height="24">Word</td>
                <td height="24" align="center">Density</td>
                <td height="24" align="center">Count</td>
              </tr>
              <?php
			  $tr = 0;
			  $words = get_3words($imp_text);
			  arsort($words);
			  foreach($words as $w=>$r)
			  {
			  if ($r == 1) continue;
			  ?>
              <tr class="tr<?php echo (($tr%2 == 0)?'1':'2'); ?>">
                <td align="left"><?php echo $w; ?></td>
                <td align="center"><?php echo round( ($r * 100) / count($words),2); ?></td>
                <td align="center"><?php echo $r; ?></td>
              </tr>
			  <?php
			  $tr++;
			  }
			  ?>
              <tr>
                <td colspan="3">&nbsp;</td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
<?php
}
require_once("footer.php");
?>